package data;

import java.util.Random;


public class ShootingData implements Comparable<ShootingData>{

	public int Generation;
	public int RobotID;
	public int Fitness;
	
	public RobotShootingData fireData;
	public RobotShootingData gunData;
	
	public ShootingData()
	{
		this.Generation = 0;
		this.RobotID = 0;
		this.Fitness = 0;
		
		this.fireData = new RobotShootingData();
		this.gunData = new RobotShootingData();
		
		this.GenerateRandomIndividual();
	}
	
	public ShootingData(ShootingData source)
	{
		this.Generation = source.Generation;
		this.RobotID = source.RobotID;
		this.Fitness = source.Fitness;
		
		this.fireData = new RobotShootingData(source.fireData);
		this.gunData = new RobotShootingData(source.gunData);
	}
	
	public void GenerateRandomIndividual()
	{
		GenerateConstants(this.fireData);
		GenerateConstants(this.gunData);
	}
	
	public void GenerateConstants(RobotShootingData dat)
	{
		Random r = new Random();
		
		dat.enemyDistance =(r.nextDouble()*2)-1; 
		dat.enemyEnergy =(r.nextDouble()*2)-1;
		dat.enemyHeading =(r.nextDouble()*2)-1;
		dat.enemyVelocity =(r.nextDouble()*2)-1;
		dat.gunHeading =(r.nextDouble()*2)-1;
		dat.meEnergy =(r.nextDouble()*2)-1;
		
	}
	
	public int compareTo(ShootingData other) {		 
		return  other.Fitness - this.Fitness; 
	}
	
	
}
